using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Decisions.HL7.Message;
using DecisionsFramework;

namespace Decisions.HL7.Message
{
    public class DataTypesAttribute:RuleAttribute
    {
        private Dictionary<HL7Version, string[]> validVersionCodes = new Dictionary<HL7Version, string[]>();
        private Dictionary<HL7Version, string[]> validVersionDescriptions = new Dictionary<HL7Version, string[]>();
        private Dictionary<HL7Version, HL7TableType> tableVersionTypes = new Dictionary<HL7Version, HL7TableType>();

        public DataTypesAttribute()
        {
            // init the values for table version types
						tableVersionTypes[HL7Version.v24] = HL7TableType.HL7;
						tableVersionTypes[HL7Version.v25] = HL7TableType.HL7;
						tableVersionTypes[HL7Version.v251] = HL7TableType.HL7;
						tableVersionTypes[HL7Version.v26] = HL7TableType.HL7;
						tableVersionTypes[HL7Version.v27] = HL7TableType.HL7;
			
            
			// init the values for version codes
						validVersionCodes[HL7Version.v24] = new string[]{"AD","CD","CE","CF","CK","CM","CN","CNE","CP","CQ","CWE","CX","DLN","DR","DT","ED","EI","FC","FN","FT","HD","ID","IS","JCC","MA","MO","NA","NM","PL","PN","PPN","PT","QIP","QSC","RCD","RI","RP","SAD","SCV","SI","SN","SRT","ST","TM","TN","TQ","TS","TX","VH","VID","XAD","XCN","XON","XPN","XTN"};
						validVersionCodes[HL7Version.v25] = new string[]{"AD","AUI","CCD","CCP","CD","CE","CF","CK","CM","CN","CNE","CNS","CP","CQ","CSU","CWE","CX","DDI","DIN","DLD","DLN","DLT","DR","DT","DTM","DTN","ED","EI","EIP","ELD","ERL","FC","FN","FT","GTS","HD","ICD","ID","IS","JCC","LA1","LA2","MA","MO","MOC","MOP","MSG","NA","NDL","NM","NR","OCD","OSD","OSP","PIP","PL","PLN","PN","PPN","PRL","PT","PTA","QIP","QSC","RCD","RFR","RI","RMC","RP","RPT","SAD","SCV","SI","SN","SPD","SPS","SRT","ST","TM","TN","TQ","TS","TX","UVC","VH","VID","VR","WVI","WVS","XAD","XCN","XON","XPN","XTN"};
						validVersionCodes[HL7Version.v251] = new string[]{"AD","AUI","CCD","CCP","CD","CE","CF","CK","CM","CN","CNE","CNS","CP","CQ","CSU","CWE","CX","DDI","DIN","DLD","DLN","DLT","DR","DT","DTM","DTN","ED","EI","EIP","LD","ERL","FC","FN","FT","GTS","HD","ICD","ID","IS","JCC","LA1","LA2","MA","MO","MOC","MOP","MSG","NA","NDL","NM","NR","OCD","OSD","OSP","PIP","PL","PLN","PN","PPN","PRL","PT","PTA","QIP","QSC","RCD","RFR","RI","RMC","RP","RPT","SAD","SCV","SI","SN","SPD","SPS","SRT","ST","TM","TN","TQ","TS","TX","UVC","VH","VID","VR","WVI","WVS","XAD","XCN","XON","XPN","XTN"};
						validVersionCodes[HL7Version.v26] = new string[]{"AD","AUI","CCD","CCP","CD","CE","CF","CK","CM","CN","CNE","CNS","CP","CQ","CSU","CWE","CX","DDI","DIN","DLD","DLN","DLT","DR","DT","DTM","DTN","ED","EI","EIP","LD","ERL","FC","FN","FT","GTS","HD","ICD","ID","IS","JCC","LA1","LA2","MA","MO","MOC","MOP","MSG","NA","NDL","NM","NR","OCD","OSD","OSP","PIP","PL","PLN","PN","PPN","PRL","PT","PTA","QIP","QSC","RCD","RFR","RI","RMC","RP","RPT","SAD","SCV","SI","SN","SPD","SPS","SRT","ST","TM","TN","TQ","TS","TX","UVC","VH","VID","VR","WVI","WVS","XAD","XCN","XON","XPN","XTN"};
						validVersionCodes[HL7Version.v27] = new string[]{"AD","AUI","CCD","CCP","CD","CE","CF","CK","CM","CN","CNE","CNN","CP","CQ","CSU","CWE","CX","DDI","DIN","DLD","DLN","DLT","DR","DT","DTM","DTN","ED","EI","EIP","ELD","ERL","FC","FN","FT","GTS","HD","ICD","ID","IS","JCC","LA1","LA2","MA","MO","MOC","MOP","MSG","NA","NDL","NM","NR","OCD","OSD","OSP","PIP","PL","PLN","PN","PPN","PRL","PT","PTA","QIP","QSC","RCD","RFR","RI","RMC","RP","RPT","SAD","SCV","SI","SN","SNM","SPD","SPS","SRT","ST","TM","TN","TQ","TS","TX","UVC","VH","VID","VR","WVI","WVS","XAD","XCN","XON","XPN","XTN"};
			
			// init the values for version descriptions
						validVersionDescriptions[HL7Version.v24] = new string[]{"Address","Channel definition","Coded element","Coded element with formatted values","Composite ID with check digit","Composite","Composite ID number and name","Coded with no exceptions","Composite price","Composite quantity with units","Coded with exceptions","Extended composite ID with check digit","Driver's license number","Date/time range","Date","Encapsulated data","Entity identifier","Financial class","Family name","Formatted text","Hierarchic designator","Coded values for HL7 tables","Coded value for user-defined tables","Job code/class","Multiplexed array","Money","Numeric array","Numeric","Person location","Person name","Performing person time stamp","Processing type","Query input parameter list","Query selection criteria","Row column definition","Repeat interval","Reference pointer","Street Address","Scheduling class value pair","Sequence ID","Structured numeric","Sort order","String","Time","Telephone number","Timing/quantity","Time stamp","Text data","Visiting hours","Version identifier","Extended address","Extended composite ID number and name","Extended composite name and ID number for organizations","Extended person name","Extended telecommunications number"};
						validVersionDescriptions[HL7Version.v25] = new string[]{"Address","Authorization information","Charge code and date","Channel calibration parameters","Channel definition","Coded element","Coded element with formatted values","Composite ID with check digit","Composite","Composite ID number and name","Coded with no exceptions","Composite ID number and name simplified","Composite price","Composite quantity with units","Channel sensitivity","Coded with exceptions","Extended composite ID with check digit","Daily deductible information","Date and institution name","Discharge to location and date","Driver's license number","Delta","Date/time range","Date","Date/time","Day type and number","Encapsulated data","Entity identifier","Entity identifier pair","Error location and description","Error location","Financial class","Family name","Formatted text","General timing specification","Hierarchic designator","Insurance certification definition","Coded values for HL7 tables","Coded value for user-defined tables","Job code/class","Location with address variation 1","Location with address variation 2","Multiplexed array","Money","Money and charge code","Money or percentage","Message type","Numeric array","Name with location and date","Numeric","Numeric range","Occurrence code and date","Order sequence definition","Occurrence span code and date","Practitioner institutional privileges","Person location","Practitioner license or other ID number","Person name","Performing person time stamp","Parent result link","Processing type","Policy type and amount","Query input parameter list","Query selection criteria","Row column definition","Reference range","Repeat interval","Room coverage","Reference pointer","Repeat pattern","Street Address","Scheduling class value pair","Sequence ID","Structured numeric","Specialty description","Specimen source","Sort order","String","Time","Telephone number","Timing/quantity","Time stamp","Text data","UB value code and amount","Visiting hours","Version identifier","Value range","Channel Identifier","Waveform source","Extended address","Extended composite ID number and name","Extended composite name and ID number for organizations","Extended person name","Extended telecommunications number"};
						validVersionDescriptions[HL7Version.v251] = new string[]{"Address","Authorization information","Charge code and date","Channel calibration parameters","Channel definition","Coded element","Coded element with formatted values","Composite ID with check digit","Composite","Composite ID number and name","Coded with no exceptions","Composite ID number and name simplified","Composite price","Composite quantity with units","Channel sensitivity","Coded with exceptions","Extended composite ID with check digit","Daily deductible information","Date and institution name","Discharge to location and date","Driver's license number","Delta","Date/time range","Date","Date/time","Day type and number","Encapsulated data","Entity identifier","Entity identifier pair","Error location and description","Error location","Financial class","Family name","Formatted text","General timing specification","Hierarchic designator","Insurance certification definition","Coded values for HL7 tables","Coded value for user-defined tables","Job code/class","Location with address variation 1","Location with address variation 2","Multiplexed array","Money","Money and charge code","Money or percentage","Message type","Numeric array","Name with location and date","Numeric","Numeric range","Occurrence code and date","Order sequence definition","Occurrence span code and date","Practitioner institutional privileges","Person location","Practitioner license or other ID number","Person name","Performing person time stamp","Parent result link","Processing type","Policy type and amount","Query input parameter list","Query selection criteria","Row column definition","Reference range","Repeat interval","Room coverage","Reference pointer","Repeat pattern","Street Address","Scheduling class value pair","Sequence ID","Structured numeric","Specialty description","Specimen source","Sort order","String","Time","Telephone number","Timing/quantity","Time stamp","Text data","UB value code and amount","Visiting hours","Version identifier","Value range","Channel Identifier","Waveform source","Extended address","Extended composite ID number and name","Extended composite name and ID number for organizations","Extended person name","Extended telecommunications number"};
						validVersionDescriptions[HL7Version.v26] = new string[]{"Address","Authorization information","Charge code and date","Channel calibration parameters","Channel definition","Coded element","Coded element with formatted values","Composite ID with check digit","Composite","Composite ID number and name","Coded with no exceptions","Composite ID number and name simplified","Composite price","Composite quantity with units","Channel sensitivity","Coded with exceptions","Extended composite ID with check digit","Daily deductible information","Date and institution name","Discharge to location and date","Driver's license number","Delta","Date/time range","Date","Date/time","Day type and number","Encapsulated data","Entity identifier","Entity identifier pair","Error location and description","Error location","Financial class","Family name","Formatted text","General timing specification","Hierarchic designator","Insurance certification definition","Coded values for HL7 tables","Coded value for user-defined tables","Job code/class","Location with address variation 1","Location with address variation 2","Multiplexed array","Money","Money and charge code","Money or percentage","Message type","Numeric array","Name with location and date","Numeric","Numeric range","Occurrence code and date","Order sequence definition","Occurrence span code and date","Practitioner institutional privileges","Person location","Practitioner license or other ID number","Person name","Performing person time stamp","Parent result link","Processing type","Policy type and amount","Query input parameter list","Query selection criteria","Row column definition","Reference range","Repeat interval","Room coverage","Reference pointer","Repeat pattern","Street Address","Scheduling class value pair","Sequence ID","Structured numeric","Specialty description","Specimen source","Sort order","String","Time","Telephone number","Timing/quantity","Time stamp","Text data","UB value code and amount","Visiting hours","Version identifier","Value range","Channel Identifier","Waveform source","Extended address","Extended composite ID number and name","Extended composite name and ID number for organizations","Extended person name","Extended telecommunications number"};
						validVersionDescriptions[HL7Version.v27] = new string[]{"Address","Authorization information","Charge code and date","Channel calibration parameters","Channel definition","Coded element","Coded element with formatted values","Composite ID with check digit","Composite","Composite ID number and name","Coded with no exceptions","Composite ID number and name simplified","Composite price","Composite quantity with units","Channel sensitivity and units","Coded with exceptions","Extended composite ID with check digit","Daily deductible information","Date and institution name","Discharge to location and date","Driver's license number","Delta","Date/time range","Date","Date/time","Day type and number","Encapsulated data","Entity identifier","Entity identifier pair","Error location and description","Error location","Financial class","Family name","Formatted text","General timing specification","Hierarchic designator","Insurance certification definition","Coded values for HL7 tables","Coded value for user-defined tables","Job code/class","Location with address variation 1","Location with address variation 2","Multiplexed array","Money","Money and charge code","Money or percentage","Message type","Numeric array","Name with date and location","Numeric","Numeric range","Occurrence code and date","Order sequence definition","Occurrence span code and date","Practitioner institutional privileges","Person location","Practitioner license or other ID number","Person name","Performing person time stamp","Parent result link","Processing type","Policy type and amount","Query input parameter list","Query selection criteria","Row column definition","Reference range","Repeat interval","Room coverage","Reference pointer","Repeat pattern","Street Address","Scheduling class value pair","Sequence ID","Structured numeric","String of telephone number digits","Specialty description","Specimen source","Sort order","String data","Time","Telephone number","Timing/quantity","Time stamp","Text data","UB value code and amount","Visiting hours","Version identifier","Value range","Channel Identifier","Waveform source","Extended address","Extended composite ID number and name for persons","Extended composite name and ID number for organizations","Extended person name","Extended telecommunications number"};
			            

        }

        
        public override ValidationIssue[] RunRule(string name, object owningObject, object value)
        {
            //todo: check if the value is valid in the current version
            //if the value is not valid in the current version, add it as a validation issue


            return new ValidationIssue[0];
        }
    }
}
